window.addEventListener('pageshow', function() {
    // 用户名
    var user_name = document.querySelector('.user_name');
    // [普通会员]栏
    var member = document.querySelector('.member');
    // 让注册填写的资料写入栏中 user_id, password, user_name, user_email, user_phone
    //1. 先去掉？ substr('起始的位置'，截取几个字符)
    var params = location.search.substr(1); //uname=andy
    //console.log(params);
    //2. 利用&把字符串分割成数组
    var arr = params.split('&');
    //console.log(arr);
    //3. 利用 = 把字符串分割成数组
    var arr2 = [];
    for (var i = 0; i < arr.length; i++) {
        arr2[i] = arr[i].split('=')[1];
    }
    for (var i = 0; i < arr.length; i++) {
        arr[i] = arr[i].split('=')[0];
    }
    //console.log(arr);
    //console.log(arr2);
    //arr2=["1", "123456", "123456", "andy", "123456%40qq.com", "123456", ""]
    //arr= ["uid", "u_password", "u_sure_password", "uname", "uemail", "uphone", "unote"]
    user_name.innerHTML = arr2[0];

    // 点击 个人资料 将数据传送给用户中心
    var account = document.querySelector('.account');
    account.addEventListener('click', function() {
        location.href = 'user.html';
        // 设置localStorage 
        for (var i = 0; i < arr.length; i++) {
            window.localStorage.setItem(arr[i], arr2[i]);
        }
    })

    // 点击 修改密码 将数据传送给用户中心
    var password = document.querySelector('.password');
    password.addEventListener('click', function() {
        location.href = 'password.html';
        // 设置localStorage 
        for (var i = 0; i < arr.length; i++) {
            window.localStorage.setItem(arr[i], arr2[i]);
        }
    })

    // 点击返回键 将已登录信息传送给首页
    var return_box = document.querySelector('.return');
    return_box.addEventListener('click', function() {
        location.href = 'index.html';
        // 设置localStorage 
        window.localStorage.setItem('flag', true);
    })

    // 点击退出登录 将已退出信息传送给首页
    var exit = document.querySelector('.exit');
    exit.addEventListener('click', function() {
        location.href = 'index.html';
        // 设置localStorage 
        window.localStorage.setItem('flag', false);
    })

    window.addEventListener('pageshow', function() {
        // 用户名
        var user_name = document.querySelector('.user_name');
        // [普通会员]栏
        var member = document.querySelector('.member');
        // 让注册填写的资料写入栏中 user_id, password, user_name, user_email, user_phone
        //1. 先去掉？ substr('起始的位置'，截取几个字符)
        var params = location.search.substr(1); //uname=andy
        //console.log(params);
        //2. 利用&把字符串分割成数组
        var arr = params.split('&');
        //console.log(arr);
        //3. 利用 = 把字符串分割成数组
        var arr2 = [];
        for (var i = 0; i < arr.length; i++) {
            arr2[i] = arr[i].split('=')[1];
        }
        for (var i = 0; i < arr.length; i++) {
            arr[i] = arr[i].split('=')[0];
        }
        //console.log(arr);
        //console.log(arr2);
        //arr2=["1", "123456", "123456", "andy", "123456%40qq.com", "123456", ""]
        //arr= ["uid", "u_password", "u_sure_password", "uname", "uemail", "uphone", "unote"]
        user_name.innerHTML = arr2[0];

        // 点击 个人资料 将数据传送给用户中心
        var account = document.querySelector('.account');
        account.addEventListener('click', function() {
            location.href = 'user.html';
            // 设置localStorage 
            for (var i = 0; i < arr.length; i++) {
                window.localStorage.setItem(arr[i], arr2[i]);
            }
        })

        // 点击 修改密码 将数据传送给用户中心
        var password = document.querySelector('.password');
        password.addEventListener('click', function() {
            location.href = 'password.html';
            // 设置localStorage 
            for (var i = 0; i < arr.length; i++) {
                window.localStorage.setItem(arr[i], arr2[i]);
            }
        })

        // 点击返回键 将已登录信息传送给首页
        var return_box = document.querySelector('.return');
        return_box.addEventListener('click', function() {
            location.href = 'index.html';
            // 设置localStorage 
            window.localStorage.setItem('flag', true);
        })

        // 点击退出登录 将已退出信息传送给首页
        var exit = document.querySelector('.exit');
        exit.addEventListener('click', function() {
            location.href = 'index.html';
            // 设置localStorage 
            window.localStorage.setItem('flag', false);
        })

    })
})